package com.ruoyi.web.controller.comlbs;


import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DriverEquipment;
import com.ruoyi.system.service.IDriverEquipmentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 负责人-设备关系Controller
 * 
 * @author wp
 * @date 2023-08-10
 */
@RestController
@RequestMapping("/comlbs/driverEquipment")
public class DriverEquipmentController extends BaseController {
    @Autowired
    private IDriverEquipmentService driverEquipmentService;

    /**
     * 查询负责人-设备关系列表
     */
    @GetMapping("/list")
    public TableDataInfo list(DriverEquipment driverEquipment) {
        startPage();
        List<DriverEquipment> list = driverEquipmentService.selectList(driverEquipment);
        return getDataTable(list);
    }

    /**
     * 导出负责人-设备关系列表
     */
    @Log(title = "负责人-设备关系", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DriverEquipment driverEquipment) {
        List<DriverEquipment> list = driverEquipmentService.selectList(driverEquipment);
        ExcelUtil<DriverEquipment> util = new ExcelUtil<DriverEquipment>(DriverEquipment.class);
        util.exportExcel(response, list, "负责人-设备关系数据");
    }

    /**
     * 获取负责人-设备关系详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(driverEquipmentService.getById(id));
    }

    /**
     * 新增负责人-设备关系
     */
    @Log(title = "负责人-设备关系", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DriverEquipment driverEquipment) {
        return toAjax(driverEquipmentService.save(driverEquipment));
    }

    /**
     * 修改负责人-设备关系
     */
    @Log(title = "负责人-设备关系", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DriverEquipment driverEquipment) {
        return toAjax(driverEquipmentService.updateById(driverEquipment));
    }

    /**
     * 删除负责人-设备关系
     */
    @Log(title = "负责人-设备关系", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(driverEquipmentService.removeByIds(Arrays.asList(ids)));
    }
}
